﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GenerateTagLinks
{
    public enum EnumTagType
    {
        TAG_A,
        TAG_URL,
        TAG_URL_NORMAL
    }

    public partial class frmResult : Form
    {
        public List<string> Keywords { get; set; }
        public List<string> Urls { get; set; }
        public string Tag { get; set; }
        public string END = Environment.NewLine;
        public EnumTagType TagType { get; set; }

        public frmResult()
        {
            InitializeComponent();
        }

        private void frmResult_Load(object sender, EventArgs e)
        {
            string txt = "/*Các trang liên quan*/" + END;

            switch (TagType)
            {
                case EnumTagType.TAG_A:
                    for (int i = 0; i < Urls.Count; i++)
                    {

                        txt += "<a href=\"" + Urls[i] + "\" target=\"_blank\">" + Keywords[i] + "</a><br/>" + END;
                    }
                    break;

                case EnumTagType.TAG_URL:
                    Tag = "URL";
                    for (int i = 0; i < Urls.Count; i++)
                    {
                        txt += "[" + Tag + "=\"" + Urls[i] + "\"]" + Keywords[i] + "[/" + Tag + "]" + END;
                    }
                    break;
                case EnumTagType.TAG_URL_NORMAL:
                    Tag = "url";
                    for (int i = 0; i < Urls.Count; i++)
                    {
                        txt += "[" + Tag + "=" + Urls[i] + "]" + Keywords[i] + "[/" + Tag + "]" + END;
                    }
                    break;
            }

            txtResult.Text = txt.Replace("&amp;", "&");
        }

        private void btnSelectAll_Click(object sender, EventArgs e)
        {
            txtResult.SelectAll();
        }
    }
}
